//
//  FKBankCardCell.m
//  HappyTest
//
//  Created by Macbook Pro on 2019/2/12.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKBankCardCell.h"

@interface FKBankCardCell ()

@property (nonatomic, weak) UIImageView *bgView;
@property (nonatomic, weak) UILabel *titleLabel;
@property (nonatomic, weak) UILabel *cardNumLabel;
@property (nonatomic, weak) UIButton *unBindBtn;

@end

@implementation FKBankCardCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UILabel *titleLabel = [UILabel fk_labelWithFont:fk_adjustFont(15) textColor:fkColor333333];
    [self.contentView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UILabel *cardNumLabel = [UILabel fk_labelWithFont:fk_adjustFont(15) textColor:fkColor333333];
    [self.contentView addSubview:cardNumLabel];
    self.cardNumLabel = cardNumLabel;
    
    UIButton *unBindBtn = [UIButton fk_btnWithTarget:self action:@selector(unBindBtnClicked) font:fk_adjustFont(12) normalTitle:@"解绑" normalTitleColor:fkColor333333 selectedTitle:nil selectedTitleColor:nil normalImg:nil selectedImg:nil bgImg:nil selectedBgImg:nil];
    [self.contentView addSubview:unBindBtn];
    self.unBindBtn = unBindBtn;
    [unBindBtn fk_viewCornerRadius:3 borderWidth:0.8 borderColor:fkColor999999];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.top.offset(fk_adjustW(20));
    }];
    [cardNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel);
        make.bottom.offset(fk_adjustW(-20));
    }];
    [unBindBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-12);
        make.centerY.offset(0);
        make.width.mas_equalTo(fk_adjustW(50));
        make.height.mas_equalTo(fk_adjustW(24));
    }];
}

- (void)unBindBtnClicked
{
    if (self.unBindBlock) {
        self.unBindBlock(self.data);
    }
}

- (void)setData:(id)data
{
    [super setData:data];
    
    self.titleLabel.text = data[@"name"];
    self.cardNumLabel.text = data[@"bank_number"];
}

@end
